Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
4.8 KiB

  1. //-----------------------------------------------------------------------------
  2. // File: DXUtil.h
  3. //
  4. // Desc: Helper functions and typing shortcuts for DirectX programming.
  5. //
  6. //@@BEGIN_MSINTERNAL
  7. //
  8. // Hist: See the source files for detailed histories
  9. // 03.21.00 - mwetzel - Last Modified
  10. //
  11. //@@END_MSINTERNAL
  12. // Copyright (c) 1997-2000 Microsoft Corporation. All rights reserved
  13. //-----------------------------------------------------------------------------
  14. #ifndef DXUTIL_H
  15. #define DXUTIL_H
  16. //-----------------------------------------------------------------------------
  17. // Miscellaneous helper functions
  18. //-----------------------------------------------------------------------------
  19. #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
  20. #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
  21. #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
  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. // 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. HRESULT DXUtil_ReadStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue, DWORD dwLength, TCHAR* strDefault );
  38. HRESULT DXUtil_ReadIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD* pdwValue, DWORD dwDefault );
  39. HRESULT DXUtil_ReadGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID* pGuidValue, GUID& guidDefault );
  40. HRESULT DXUtil_ReadBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL* pbValue, BOOL bDefault );
  41. //-----------------------------------------------------------------------------
  42. // Name: DXUtil_Timer()
  43. // Desc: Performs timer opertations. Use the following commands:
  44. // TIMER_RESET - to reset the timer
  45. // TIMER_START - to start the timer
  46. // TIMER_STOP - to stop (or pause) the timer
  47. // TIMER_ADVANCE - to advance the timer by 0.1 seconds
  48. // TIMER_GETABSOLUTETIME - to get the absolute system time
  49. // TIMER_GETAPPTIME - to get the current time
  50. // TIMER_GETELAPSEDTIME - to get the time that elapsed between
  51. // TIMER_GETELAPSEDTIME calls
  52. //-----------------------------------------------------------------------------
  53. enum TIMER_COMMAND { TIMER_RESET, TIMER_START, TIMER_STOP, TIMER_ADVANCE,
  54. TIMER_GETABSOLUTETIME, TIMER_GETAPPTIME, TIMER_GETELAPSEDTIME };
  55. FLOAT __stdcall DXUtil_Timer( TIMER_COMMAND command );
  56. //-----------------------------------------------------------------------------
  57. // UNICODE support for converting between CHAR, TCHAR, and WCHAR strings
  58. //-----------------------------------------------------------------------------
  59. VOID DXUtil_ConvertAnsiStringToWide( WCHAR* wstrDestination, const CHAR* strSource, int cchDestChar = -1 );
  60. VOID DXUtil_ConvertWideStringToAnsi( CHAR* strDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
  61. VOID DXUtil_ConvertGenericStringToAnsi( CHAR* strDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
  62. VOID DXUtil_ConvertGenericStringToWide( WCHAR* wstrDestination, const TCHAR* tstrSource, int cchDestChar = -1 );
  63. VOID DXUtil_ConvertAnsiStringToGeneric( TCHAR* tstrDestination, const CHAR* strSource, int cchDestChar = -1 );
  64. VOID DXUtil_ConvertWideStringToGeneric( TCHAR* tstrDestination, const WCHAR* wstrSource, int cchDestChar = -1 );
  65. //-----------------------------------------------------------------------------
  66. // Debug printing support
  67. //-----------------------------------------------------------------------------
  68. VOID DXUtil_Trace( TCHAR* strMsg, ... );
  69. HRESULT _DbgOut( TCHAR*, DWORD, HRESULT, TCHAR* );
  70. #if defined(DEBUG) | defined(_DEBUG)
  71. #define DXTRACE DXUtil_Trace
  72. #else
  73. #define DXTRACE sizeof
  74. #endif
  75. #if defined(DEBUG) | defined(_DEBUG)
  76. #define DEBUG_MSG(str) _DbgOut( __FILE__, (DWORD)__LINE__, 0, str )
  77. #else
  78. #define DEBUG_MSG(str) (0L)
  79. #endif
  80. #endif // DXUTIL_H