Source code of Windows XP (NT5)
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.

161 lines
5.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: util.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #ifndef _UTIL_H_
  11. #define _UTIL_H_
  12. #define fTRUE TRUE
  13. #define fFALSE FALSE
  14. #define pNIL ( NULL )
  15. #define lpNIL ( NULL )
  16. #define hNIL ( (HANDLE)NULL )
  17. #define hwndNIL ( (HWND)NULL )
  18. #define hkeyNIL ( (HKEY)NULL )
  19. #define dwNIL ( (DWORD)NULL )
  20. #define uNIL ( (UINT)NULL )
  21. #define nNIL ( -1 )
  22. #define cNIL ( '\0' )
  23. #define szNIL ( L"" )
  24. #define cBACKSLASH '\\'
  25. #define cPERIOD '.'
  26. #define cSLASH '/'
  27. #define cMINUS '-'
  28. #define cPLUS '+'
  29. #define cSPACE ' '
  30. #define cDBLQUOTE '\"'
  31. #define cTILDE L'~'
  32. #define cLOWER_A 'a'
  33. #define cLOWER_Z 'z'
  34. #define cUPPER_A 'A'
  35. #define cUPPER_H 'H'
  36. #define cUPPER_Q 'Q'
  37. #define cUPPER_R 'R'
  38. #define cUPPER_S 'S'
  39. #define cUPPER_V 'V'
  40. #define cUPPER_Z 'Z'
  41. #define cZERO '0'
  42. #define cNINE '9'
  43. #define szBACKSLASH L"\\"
  44. #define szSPACE " "
  45. #define szCRLF "\r\n"
  46. #define szPERIOD L"."
  47. #define szDOTDOT ".."
  48. #define szPREVDIR L".."
  49. #define bMSG_HANDLED 0
  50. #define bMSG_NOTHANDLED 1
  51. #define bDLG_MSG_HANDLED 1
  52. #define bDLG_MSG_NOTHANDLED 0
  53. #define cbSMALL_SZ 64
  54. #define cbLARGE_SZ 128
  55. #define cbMAX_SZ 256
  56. #define nREALLOC_INC 512
  57. #define CchSz( sz ) lstrlen(sz)
  58. #define CbSz( sz ) ( lstrlen(sz) + 1 )
  59. #define CchWsz( sz ) SzLenW(sz)
  60. #define CbWsz( sz ) ( (SzLenW(sz)+1)*sizeof(WCHAR) )
  61. #define MemAlloc( dw ) LocalAlloc( LPTR, dw )
  62. #define MemReAlloc( lp, dw ) LocalReAlloc( lp, dw, (UINT)0 )
  63. #define MemFree( lpv ) { LocalFree( lpv ); lpv = 0; }
  64. #define ExitOnTrue( f ) if( f ) goto lExit;
  65. #define ExitOnFalse( f ) if( !(f) ) goto lExit;
  66. #define ExitOnNull( x ) if( (x) == NULL ) goto lExit;
  67. #define ExitOnFail( hr ) if( FAILED(hr) ) goto lExit;
  68. #define FailOnTrue( f ) if( f ) goto lErr;
  69. #define FailOnFalse( f ) if( !(f) ) goto lErr;
  70. #define FailOnNull( x ) if( (x) == NULL ) goto lErr;
  71. #define FailOnFail( hr ) if( FAILED(hr) ) goto lErr;
  72. #define GotoErrSet( cmd ) { cmd; goto lErr; }
  73. #define SzBool( f ) ( (f) ? "TRUE" : "FALSE" )
  74. #define Validate_Number( n, nMin, nMax ) \
  75. n = min( nMax, max( nMin, n ) )
  76. INT StrTblMsgBox( HWND hwnd, UINT uTextID, UINT uTitleID, DWORD dwFlags );
  77. BOOL CenterWindow( HWND hwnd, HWND hwndRef );
  78. BOOL DirectoryExists( LPWSTR szDir );
  79. BOOL GetReceivedFilesFolder( LPWSTR szDir, DWORD dwLen );
  80. BOOL GetUniqueName( LPWSTR szPath, LPWSTR szBase, BOOL fFile );
  81. BOOL FileExists( LPWSTR szFile );
  82. BOOL IsChecked( HWND hwnd );
  83. BOOL IsCharInStr( CHAR c, LPWSTR sz );
  84. BOOL IsRoomForFile( __int64 dwFileSize, LPWSTR szPath );
  85. BOOL bNoTrailingSlash( LPWSTR szPath );
  86. #define bHasTrailingSlash(_a) (!(bNoTrailingSlash(_a)))
  87. VOID SetCreateParams( HINSTANCE hInst, HWND hwndParent, HFONT hFont );
  88. HWND CreateCheckBox( HINSTANCE hInst, HWND hwndParent, LPWSTR szText, DWORD dwExStyle );
  89. HWND CreateGroupBox( HINSTANCE hInst, HWND hwndParent, LPWSTR szText, DWORD dwExStyle );
  90. HWND CreateMultiLineEditBox( HINSTANCE hInst, HWND hwndParent, LPWSTR szText, DWORD dwExStyle );
  91. HWND CreatePushButton( HINSTANCE hInst, HWND hwndParent, LPWSTR szText, UINT uID, DWORD dwExStyle );
  92. HWND CreateRadioButton( HINSTANCE hInst, HWND hwndParent, LPWSTR szText, DWORD dwExStyle );
  93. HWND CreateSingleLineEditBox( HINSTANCE hInst, HWND hwndParent, LPWSTR szText, DWORD dwExStyle );
  94. HWND CreateStatic( HINSTANCE hInst, HWND hwndParent, LPWSTR szText, DWORD dwExStyle );
  95. HWND CreateTabControl( HINSTANCE hInst, HWND hwndParent, DWORD dwExStyle );
  96. HWND CreateAnimation( HINSTANCE hInst, HWND hwndParent, UINT uID, DWORD dwExStyle );
  97. HWND CreateStatusBar( HINSTANCE hInst, HWND hwndParent, DWORD dwExStyle );
  98. HWND CreateProgressBar( HINSTANCE hInst, HWND hwndParent, DWORD dwExStyle );
  99. HWND CreateListView(HINSTANCE hInst, HWND hwndParent, DWORD dwExStyle);
  100. VOID StripPath( LPWSTR szFullPath );
  101. VOID StripPathW( LPWSTR wszFullPath );
  102. VOID StripFile( LPWSTR szFullPath );
  103. VOID StripExt( LPWSTR szFullPath );
  104. LPWSTR GetFileName( LPWSTR szFullPath );
  105. LPWSTR GetFileNameW( LPWSTR wszFullPath );
  106. typedef enum {
  107. LTB_NULL_TERM = 0,
  108. LTB_SPACE_SEP = 1,
  109. } LIST_TYPE;
  110. LPWSTR DropListToBuffer( HDROP hDrop, LIST_TYPE listType );
  111. LPWSTR OpenFileListToBuffer( LPWSTR pszFileList, LIST_TYPE listType );
  112. VOID ShowReceivedFilesFolder( void );
  113. DWORD GetDirectorySize( LPWSTR szFolder );
  114. VOID BringWndToTop( HWND hwnd );
  115. VOID Rest( DWORD dwMilliseconds );
  116. WPARAM DoMsgLoop( BOOL fForever );
  117. BOOL ProcessMessageIfAvailable();
  118. BOOL ProcessMessage();
  119. LPWSTR SzSz( LPCSTR pszStr, LPCSTR pszFind );
  120. LPWSTR SzSzI( LPCSTR szStr, LPCSTR szFind );
  121. INT SzCmpN( LPCSTR lpsz1, LPCSTR lpsz2, INT nLen );
  122. LPSTR WszToSz( LPCWSTR lpwsz );
  123. LPWSTR SzToWsz( LPCSTR lpsz );
  124. INT SzLenW( LPCWSTR lpwsz );
  125. LPWSTR SzCpyW( LPWSTR lpsz1, LPCWSTR lpsz2 );
  126. HRESULT ResolveShortCut( LPWSTR pszShortcut, LPWSTR lpszResolved );
  127. HANDLE WaitForMutex( LPWSTR pszMutexName, DWORD dwRetryTime, DWORD dwTimeout );
  128. BOOL FileTimeToUnixTime( LPFILETIME lpFileTime, LPDWORD pdwUnixTime );
  129. BOOL UnixTimeToFileTime( DWORD dwUnixTime, LPFILETIME lpFileTime );
  130. #endif // _UTIL_H_