home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / Common / include / dxutil.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-31  |  5.0 KB  |  113 lines

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