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.

85 lines
3.0 KiB

  1. //
  2. // Microsoft Windows Media Technologies
  3. // Copyright (C) Microsoft Corporation, 1999 - 2001. All rights reserved.
  4. //
  5. //
  6. // This workspace contains two projects -
  7. // 1. ProgHelp which implements the Progress Interface
  8. // 2. The Sample application WmdmApp.
  9. //
  10. // ProgHelp.dll needs to be registered first for the SampleApp to run.
  11. #ifndef _UTIL_H
  12. #define _UTIL_H
  13. // Macros
  14. //
  15. #define MemAlloc( dw ) LocalAlloc( LPTR, dw )
  16. #define MemFree( lpv ) { LocalFree( lpv ); lpv = NULL; }
  17. #define ExitOnTrue( f ) if( f ) goto lExit;
  18. #define ExitOnFalse( f ) if( !(f) ) goto lExit;
  19. #define ExitOnNull( x ) if( (x) == NULL ) goto lExit;
  20. #define ExitOnFail( hr ) if( FAILED(hr) ) goto lExit;
  21. #define FailOnTrue( f ) if( f ) goto lErr;
  22. #define FailOnFalse( f ) if( !(f) ) goto lErr;
  23. #define FailOnNull( x ) if( (x) == NULL ) goto lErr;
  24. #define FailOnFail( hr ) if( FAILED(hr) ) goto lErr;
  25. #define SafeRelease( i ) { if( (i) ) i->Release(); i = NULL; }
  26. // Flags for DropListToBuffer
  27. //
  28. typedef enum {
  29. LTB_NULL_TERM = 0,
  30. LTB_SPACE_SEP = 1,
  31. } LIST_TYPE;
  32. // Util functions
  33. //
  34. BOOL CenterWindow( HWND hwnd, HWND hwndRef );
  35. VOID BringWndToTop( HWND hwnd );
  36. DWORD GetTheFileSize( LPSTR pszFile );
  37. VOID StripPath( LPSTR szFullPath );
  38. LPSTR GetFileName( LPSTR szFullPath );
  39. WPARAM DoMsgLoop( BOOL fForever );
  40. VOID UiYield( void );
  41. LPSTR DropListToBuffer( HDROP hDrop, LIST_TYPE listType, UINT *uNumObjs );
  42. VOID SetRegistryParams( HINSTANCE hInst, HKEY hkeyRoot );
  43. VOID WriteRegDword(LPSTR szPath, LPSTR szKey, DWORD dwValue);
  44. VOID WriteRegDword_StrTbl(UINT uPathID, UINT uKeyID, DWORD dwValue);
  45. VOID WriteRegStr(LPSTR szPath, LPSTR szKey, LPSTR szValue);
  46. VOID WriteRegStr_StrTbl(UINT uPathID, UINT uKeyID, LPSTR szValue);
  47. DWORD GetRegDword(LPSTR szPath, LPSTR szKey, DWORD dwDefault, BOOL bStore);
  48. DWORD GetRegDword_StrTbl(UINT uPathID, UINT uKeyID, DWORD dwDefault, BOOL bStore);
  49. LPSTR GetRegStr(LPSTR szPath, LPSTR szKey, LPSTR szDefault, BOOL bStore);
  50. LPSTR GetRegStr_StrTbl(UINT uPathID, UINT uKeyID, LPSTR szDefault, BOOL bStore);
  51. LPSTR GetRegStr_StrTblDefault(UINT uPathID, UINT uKeyID, UINT uDefaultID, BOOL bStore);
  52. HANDLE WaitForMutex( LPSTR pszMutexName, DWORD dwRetryTime, DWORD dwTimeout );
  53. LPSTR FormatBytesToSz( DWORD dwLowBytes, DWORD dwHighBytes, DWORD dwMultiplier, LPSTR psz, size_t cbMax);
  54. LPSTR FormatBytesToKB_Sz( DWORD dwBytes, LPSTR pszKB, size_t cbMax );
  55. LPSTR FormatKBToKB_Sz( DWORD dwKB, LPSTR pszKB, size_t cbMax );
  56. LPSTR FormatKBToMB_Sz( DWORD dwKB, LPSTR pszMB, size_t cbMax );
  57. LPSTR FormatSystemTimeToSz( SYSTEMTIME *pSysTime, LPSTR pszDateTime, DWORD cchMax );
  58. LPARAM ListView_GetLParam( HWND hwndListView, INT nItem );
  59. LPARAM TreeView_GetLParam( HWND hwndTreeView, HTREEITEM hItem );
  60. BOOL TreeView_SetLParam( HWND hwndTreeView, HTREEITEM hItem, LPARAM lParam );
  61. INT GetShellIconIndex( LPCSTR pszItemName, LPTSTR szTypeBuffer, UINT cMaxChars );
  62. HICON GetShellIcon( LPCSTR pszItemName, BOOL bDirectory );
  63. #endif // _UTIL_H