home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / DirectX8 / dx8a_sdk.exe / samples / multimedia / common / include / dxutil.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-04  |  4.7 KB  |  104 lines

  1. //-----------------------------------------------------------------------------
  2. // File: DXUtil.h
  3. //
  4. // Desc: Helper functions and typing shortcuts for DirectX programming.
  5. //
  6. // Copyright (c) 1997-2000 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. // Debug printing support
  84. //-----------------------------------------------------------------------------
  85. VOID    DXUtil_Trace( TCHAR* strMsg, ... );
  86. HRESULT _DbgOut( TCHAR*, DWORD, HRESULT, TCHAR* );
  87.  
  88. #if defined(DEBUG) | defined(_DEBUG)
  89.     #define DXTRACE           DXUtil_Trace
  90. #else
  91.     #define DXTRACE           sizeof
  92. #endif
  93.  
  94. #if defined(DEBUG) | defined(_DEBUG)
  95.     #define DEBUG_MSG(str)    _DbgOut( __FILE__, (DWORD)__LINE__, 0, str )
  96. #else
  97.     #define DEBUG_MSG(str)    (0L)
  98. #endif
  99.  
  100.  
  101.  
  102.  
  103. #endif // DXUTIL_H
  104.