dxutil.h
上传用户:luhy168
上传日期:2022-01-10
资源大小:240k
文件大小:5k
源码类别:

模拟服务器

开发平台:

Visual C++

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