0001:
0002:
0003:
0004:
0005:
0006: #ifndef DXUTIL_H
0007: #define DXUTIL_H
0008:
0009:
0010:
0011:
0012:
0013: #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
0014: #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
0015: #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
0016:
0017:
0018: #ifndef UNDER_CE
0019:
0020:
0021:
0022:
0023:
0024: HRESULT DXUtil_GetDXSDKMediaPathCch( TCHAR* strDest, int cchDest );
0025: HRESULT DXUtil_GetDXSDKMediaPathCb( TCHAR* szDest, int cbDest );
0026: HRESULT DXUtil_FindMediaFileCch( TCHAR* strDestPath, int cchDest, TCHAR* strFilename );
0027: HRESULT DXUtil_FindMediaFileCb( TCHAR* szDestPath, int cbDest, TCHAR* strFilename );
0028: #endif
0029:
0030:
0031:
0032:
0033:
0034:
0035: HRESULT DXUtil_WriteStringRegKey( HKEY hKey, TCHAR* strRegName, TCHAR* strValue );
0036: HRESULT DXUtil_WriteIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD dwValue );
0037: HRESULT DXUtil_WriteGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID guidValue );
0038: HRESULT DXUtil_WriteBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL bValue );
0039:
0040: HRESULT DXUtil_ReadStringRegKeyCch( HKEY hKey, TCHAR* strRegName, TCHAR* strDest, DWORD cchDest, TCHAR* strDefault );
0041: HRESULT DXUtil_ReadStringRegKeyCb( HKEY hKey, TCHAR* strRegName, TCHAR* strDest, DWORD cbDest, TCHAR* strDefault );
0042: HRESULT DXUtil_ReadIntRegKey( HKEY hKey, TCHAR* strRegName, DWORD* pdwValue, DWORD dwDefault );
0043: HRESULT DXUtil_ReadGuidRegKey( HKEY hKey, TCHAR* strRegName, GUID* pGuidValue, GUID& guidDefault );
0044: HRESULT DXUtil_ReadBoolRegKey( HKEY hKey, TCHAR* strRegName, BOOL* pbValue, BOOL bDefault );
0045:
0046:
0047:
0048:
0049:
0050:
0051:
0052:
0053:
0054:
0055:
0056:
0057:
0058:
0059: enum TIMER_COMMAND { TIMER_RESET, TIMER_START, TIMER_STOP, TIMER_ADVANCE,
0060: TIMER_GETABSOLUTETIME, TIMER_GETAPPTIME, TIMER_GETELAPSEDTIME };
0061: FLOAT __stdcall DXUtil_Timer( TIMER_COMMAND command );
0062:
0063:
0064:
0065:
0066:
0067: HRESULT DXUtil_ConvertAnsiStringToWideCch( WCHAR* wstrDestination, const CHAR* strSource, int cchDestChar );
0068: HRESULT DXUtil_ConvertWideStringToAnsiCch( CHAR* strDestination, const WCHAR* wstrSource, int cchDestChar );
0069: HRESULT DXUtil_ConvertGenericStringToAnsiCch( CHAR* strDestination, const TCHAR* tstrSource, int cchDestChar );
0070: HRESULT DXUtil_ConvertGenericStringToWideCch( WCHAR* wstrDestination, const TCHAR* tstrSource, int cchDestChar );
0071: HRESULT DXUtil_ConvertAnsiStringToGenericCch( TCHAR* tstrDestination, const CHAR* strSource, int cchDestChar );
0072: HRESULT DXUtil_ConvertWideStringToGenericCch( TCHAR* tstrDestination, const WCHAR* wstrSource, int cchDestChar );
0073: HRESULT DXUtil_ConvertAnsiStringToWideCb( WCHAR* wstrDestination, const CHAR* strSource, int cbDestChar );
0074: HRESULT DXUtil_ConvertWideStringToAnsiCb( CHAR* strDestination, const WCHAR* wstrSource, int cbDestChar );
0075: HRESULT DXUtil_ConvertGenericStringToAnsiCb( CHAR* strDestination, const TCHAR* tstrSource, int cbDestChar );
0076: HRESULT DXUtil_ConvertGenericStringToWideCb( WCHAR* wstrDestination, const TCHAR* tstrSource, int cbDestChar );
0077: HRESULT DXUtil_ConvertAnsiStringToGenericCb( TCHAR* tstrDestination, const CHAR* strSource, int cbDestChar );
0078: HRESULT DXUtil_ConvertWideStringToGenericCb( TCHAR* tstrDestination, const WCHAR* wstrSource, int cbDestChar );
0079:
0080:
0081:
0082:
0083:
0084: VOID DXUtil_LaunchReadme( HWND hWnd, TCHAR* strLoc = NULL );
0085:
0086:
0087:
0088:
0089: HRESULT DXUtil_ConvertGUIDToStringCch( const GUID* pGuidSrc, TCHAR* strDest, int cchDestChar );
0090: HRESULT DXUtil_ConvertGUIDToStringCb( const GUID* pGuidSrc, TCHAR* strDest, int cbDestChar );
0091: HRESULT DXUtil_ConvertStringToGUID( const TCHAR* strIn, GUID* pGuidOut );
0092:
0093:
0094:
0095:
0096:
0097:
0098: VOID DXUtil_Trace( TCHAR* strMsg, ... );
0099:
0100: #if defined(DEBUG) | defined(_DEBUG)
0101: #define DXTRACE DXUtil_Trace
0102: #else
0103: #define DXTRACE sizeof
0104: #endif
0105:
0106:
0107:
0108:
0109:
0110:
0111: enum ArrayListType
0112: {
0113: AL_VALUE,
0114: AL_REFERENCE,
0115: };
0116:
0117:
0118:
0119:
0120:
0121:
0122: class CArrayList
0123: {
0124: protected:
0125: ArrayListType m_ArrayListType;
0126: void* m_pData;
0127: UINT m_BytesPerEntry;
0128: UINT m_NumEntries;
0129: UINT m_NumEntriesAllocated;
0130:
0131: public:
0132: CArrayList( ArrayListType Type, UINT BytesPerEntry = 0 );
0133: ~CArrayList( void );
0134: HRESULT Add( void* pEntry );
0135: void Remove( UINT Entry );
0136: void* GetPtr( UINT Entry );
0137: UINT Count( void ) { return m_NumEntries; }
0138: bool Contains( void* pEntryData );
0139: void Clear( void ) { m_NumEntries = 0; }
0140: };
0141:
0142:
0143:
0144:
0145:
0146: #ifdef UNDER_CE
0147:
0148: #define CheckDlgButton(hdialog, id, state) ::SendMessage(::GetDlgItem(hdialog, id), BM_SETCHECK, state, 0)
0149: #define IsDlgButtonChecked(hdialog, id) ::SendMessage(::GetDlgItem(hdialog, id), BM_GETCHECK, 0L, 0L)
0150: #define GETTIMESTAMP GetTickCount
0151: #define _TWINCE(x) _T(x)
0152:
0153: __inline int GetScrollPos(HWND hWnd, int nBar)
0154: {
0155: SCROLLINFO si;
0156: memset(&si, 0, sizeof(si));
0157: si.cbSize = sizeof(si);
0158: si.fMask = SIF_POS;
0159: if (!GetScrollInfo(hWnd, nBar, &si))
0160: {
0161: return 0;
0162: }
0163: else
0164: {
0165: return si.nPos;
0166: }
0167: }
0168:
0169: #else
0170:
0171: #define GETTIMESTAMP timeGetTime
0172: #define _TWINCE(x) x
0173:
0174: #endif
0175:
0176:
0177: #endif
0178: