| 11 | cycrow | 1 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 2 | // File: DXUtil.h
 | 
        
           |  |  | 3 | //
 | 
        
           |  |  | 4 | // Desc: DirectShow sample code - helper functions and typing shortcuts for 
 | 
        
           |  |  | 5 | //       DirectX programming.
 | 
        
           |  |  | 6 | //
 | 
        
           |  |  | 7 | // Copyright (c) Microsoft Corporation.  All rights reserved
 | 
        
           |  |  | 8 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 9 |   | 
        
           |  |  | 10 | #ifndef DXUTIL_H
 | 
        
           |  |  | 11 | #define DXUTIL_H
 | 
        
           |  |  | 12 |   | 
        
           |  |  | 13 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 14 | // Miscellaneous helper functions
 | 
        
           |  |  | 15 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 16 | #define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
 | 
        
           |  |  | 17 | #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p);   (p)=NULL; } }
 | 
        
           |  |  | 18 | #define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }
 | 
        
           |  |  | 19 |   | 
        
           |  |  | 20 |   | 
        
           |  |  | 21 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 22 | // Name: DXUtil_GetDXSDKMediaPath()
 | 
        
           |  |  | 23 | // Desc: Returns the DirectX SDK path, as stored in the system registry
 | 
        
           |  |  | 24 | //       during the SDK install.
 | 
        
           |  |  | 25 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 26 | const TCHAR* DXUtil_GetDXSDKMediaPath();
 | 
        
           |  |  | 27 |   | 
        
           |  |  | 28 |   | 
        
           |  |  | 29 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 30 | // Name: DXUtil_Read*RegKey() and DXUtil_Write*RegKey()
 | 
        
           |  |  | 31 | // Desc: Helper functions to read/write a string registry key 
 | 
        
           |  |  | 32 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 33 | HRESULT DXUtil_WriteStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue );
 | 
        
           |  |  | 34 | HRESULT DXUtil_WriteIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD dwValue );
 | 
        
           |  |  | 35 | HRESULT DXUtil_WriteGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID guidValue );
 | 
        
           |  |  | 36 | HRESULT DXUtil_WriteBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL bValue );
 | 
        
           |  |  | 37 |   | 
        
           |  |  | 38 | HRESULT DXUtil_ReadStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue, DWORD dwLength, TCHAR* strDefault );
 | 
        
           |  |  | 39 | HRESULT DXUtil_ReadIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD* pdwValue, DWORD dwDefault );
 | 
        
           |  |  | 40 | HRESULT DXUtil_ReadGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID* pGuidValue, GUID& guidDefault );
 | 
        
           |  |  | 41 | HRESULT DXUtil_ReadBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL* pbValue, BOOL bDefault );
 | 
        
           |  |  | 42 |   | 
        
           |  |  | 43 |   | 
        
           |  |  | 44 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 45 | // Name: DXUtil_Timer()
 | 
        
           |  |  | 46 | // Desc: Performs timer opertations. Use the following commands:
 | 
        
           |  |  | 47 | //          TIMER_RESET           - to reset the timer
 | 
        
           |  |  | 48 | //          TIMER_START           - to start the timer
 | 
        
           |  |  | 49 | //          TIMER_STOP            - to stop (or pause) the timer
 | 
        
           |  |  | 50 | //          TIMER_ADVANCE         - to advance the timer by 0.1 seconds
 | 
        
           |  |  | 51 | //          TIMER_GETABSOLUTETIME - to get the absolute system time
 | 
        
           |  |  | 52 | //          TIMER_GETAPPTIME      - to get the current time
 | 
        
           |  |  | 53 | //          TIMER_GETELAPSEDTIME  - to get the time that elapsed between 
 | 
        
           |  |  | 54 | //                                  TIMER_GETELAPSEDTIME calls
 | 
        
           |  |  | 55 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 56 | enum TIMER_COMMAND { TIMER_RESET, TIMER_START, TIMER_STOP, TIMER_ADVANCE,
 | 
        
           |  |  | 57 |                      TIMER_GETABSOLUTETIME, TIMER_GETAPPTIME, TIMER_GETELAPSEDTIME };
 | 
        
           |  |  | 58 | FLOAT __stdcall DXUtil_Timer( TIMER_COMMAND command );
 | 
        
           |  |  | 59 |   | 
        
           |  |  | 60 |   | 
        
           |  |  | 61 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 62 | // UNICODE support for converting between CHAR, TCHAR, and WCHAR strings
 | 
        
           |  |  | 63 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 64 | VOID DXUtil_ConvertAnsiStringToWide( WCHAR* wstrDestination, const CHAR* strSource, int cchDestChar = -1 );
 | 
        
           |  |  | 65 | VOID DXUtil_ConvertWideStringToAnsi( CHAR* strDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
 | 
        
           |  |  | 66 | VOID DXUtil_ConvertGenericStringToAnsi( CHAR* strDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
 | 
        
           |  |  | 67 | VOID DXUtil_ConvertGenericStringToWide( WCHAR* wstrDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
 | 
        
           |  |  | 68 | VOID DXUtil_ConvertAnsiStringToGeneric( TCHAR* tstrDestination, const CHAR* strSource, int cchDestChar = -1 );
 | 
        
           |  |  | 69 | VOID DXUtil_ConvertWideStringToGeneric( TCHAR* tstrDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
 | 
        
           |  |  | 70 |   | 
        
           |  |  | 71 |   | 
        
           |  |  | 72 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 73 | // Debug printing support
 | 
        
           |  |  | 74 | //-----------------------------------------------------------------------------
 | 
        
           |  |  | 75 | VOID    DXUtil_Trace( TCHAR* strMsg, ... );
 | 
        
           |  |  | 76 | HRESULT _DbgOut( TCHAR*, DWORD, HRESULT, TCHAR* );
 | 
        
           |  |  | 77 |   | 
        
           |  |  | 78 | #if defined(DEBUG) | defined(_DEBUG)
 | 
        
           |  |  | 79 |     #define DXTRACE           DXUtil_Trace
 | 
        
           |  |  | 80 | #else
 | 
        
           |  |  | 81 |     #define DXTRACE           sizeof
 | 
        
           |  |  | 82 | #endif
 | 
        
           |  |  | 83 |   | 
        
           |  |  | 84 | #if defined(DEBUG) | defined(_DEBUG)
 | 
        
           |  |  | 85 |     #define DEBUG_MSG(str)    _DbgOut( __FILE__, (DWORD)__LINE__, 0, str )
 | 
        
           |  |  | 86 | #else
 | 
        
           |  |  | 87 |     #define DEBUG_MSG(str)    (0L)
 | 
        
           |  |  | 88 | #endif
 | 
        
           |  |  | 89 |   | 
        
           |  |  | 90 |   | 
        
           |  |  | 91 |   | 
        
           |  |  | 92 |   | 
        
           |  |  | 93 | #endif // DXUTIL_H
 | 
        
           |  |  | 94 |   | 
        
           |  |  | 95 |   |